import 'package:flutter/material.dart';
import 'package:mypeiwan/pages/peiwanshipage.dart';

import 'businesspage.dart';
import 'chatpage.dart';
import 'homepage.dart';
import 'mypage.dart';

class MainPage extends StatefulWidget {
  const MainPage({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  var allPages = [
    HomePage(),
    PeiwanshiPage(),
    ChatPage(),
    BusinessPage(),
    MyPage()
  ];
  var currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: allPages[currentIndex],
      backgroundColor: Colors.green,
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: currentIndex,
        type: BottomNavigationBarType.fixed,
        unselectedItemColor: Colors.grey,
        selectedItemColor: Colors.blue,
        /*unselectedLabelStyle:TextStyle(
          color: Colors.black
        ),*/
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: "首页",
            //backgroundColor:Colors.blue
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.people),
            label: "陪玩师",
            //backgroundColor:Colors.blue
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.chat),
            label: "聊天",
            //backgroundColor:Colors.blue
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.shop),
            label: "商家",
            //backgroundColor:Colors.blue
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person),
            label: "我的",
            //backgroundColor:Colors.blue
          ),
        ],
        onTap: (index) {
          setState(() {
            print("the index is :$index");
            currentIndex = index;
          });
        },
      ),
    );
  }
}
